import json
import time
from datetime import datetime
from kafka import KafkaProducer

from common.basic2 import send_message_to_kafka, upate_meassage_id, save_file, upate_meassage_time, \
    generate_random_string

#  报文内容
data = {
    "packetType": "http",
    "data": {
        "id": None,
        "httpType": 1,
        "host": "10.10.2.233:65523",
        "port": 65523,
        "httpDirection": 2,
        "uri": "/api/pythonTest/gogo",
        "fullUri": "http://10.10.2.233:65523/api/pythonTest/gogo",
        "requestIp": "127.0.0.2",
        "requestMethod": "POST",
        "requestTime": None,
        "requestTimestamp": None,
        "requestTimestampStr": None,
        "requestContentLength": 110,
        "requestContentType": "application/json",
        "requestHeader": "{\"Referer\":\"http://10.10.2.236:31269\",\"Origin\":\"10.10.2.233:31101\",\"User-Agent\":\"POSTMAN\",\"Accept\":\"text/plain, application/json, application/*+json, */*\",\"Connection\":\"Keep-Alive\",\"Host\":\"10.10.2.240:32381\",\"Accept-Encoding\":\"gzip,deflate\",\"Content-Length\":\"110\",\"Content-Type\":\"application/json\"}",
        "requestBody": "{\"username\": \"drs\",\"id\": \"10019102\"}",
        "sensitiveChars": None,
        "statusCode": 200,
        "costTime": 18,
        "responseIp": "10.10.2.240",
        "responseTime": None,
        "responseTimestamp": None,
        "responseTimestampStr": None,
        "responseContentLength": 0,
        "responseContentType": "application/json",
        "responseHeader": "{\"Set-Cookie\":\"name=123123;SameSite=strict\",\"Access-Control-Allow-Origin\":\"*\",\"Transfer-Encoding\":\"chunked\",\"Keep-Alive\":\"timeout=60\",\"Connection\":\"keep-alive\",\"Vary\":\"Access-Control-Request-Headers\",\"Date\":\"Mon, 10 Oct 2022 13:54:38 GMT\",\"Content-Type\":\"application/json\"}",
        "responseBody": "{\"code\":\"200\",\"msg\":\"hello\",\"id\": \"12232345\"}}",
        "complete": True,
        "project": "scan_api"
    }
}

# 替换I